package com.challenger.teacher.services.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.challenger.teacher.dao.TeacherDao;
import com.challenger.teacher.dao.TeacherUsrDao;
import com.challenger.teacher.entity.Teacher;
import com.challenger.teacher.entity.TeacherUsr;
import com.challenger.teacher.services.TeacherService;
/**
 * 教师业务访问接口实现类
 * @author 古振猛 404879269@qq.com
 *
 */
public class TeacherServiceImpl implements TeacherService {
	private TeacherDao teacherDao;
	private TeacherUsrDao teacherUsrDao;
	@Override
	public Teacher findTeacherByInrid(int inrid) {
		return this.teacherDao.findTeacherByInrid(inrid);
	}

	@Override
	public int insertTeacher(Teacher teacher, TeacherUsr teacherUsr) {
		int m = this.teacherDao.insertTeacher(teacher);
		int n = this.teacherUsrDao.insertTeacherUsr(teacherUsr);
		if (m + n == 2) {
			return 1;
		} else {
			return 0;
		}
	}

	@Override
	public int updateTeacher(Teacher teacher, TeacherUsr teacherUsr) {
		int m = this.teacherDao.updateTeacher(teacher);
		int n = this.teacherUsrDao.updateTeacherUsr(teacherUsr);
		if (m + n == 2) {
			return 1;
		} else {
			return 0;
		}
	}

	@Override
	public List<Teacher> login(String uid, String upword) {
		Map paraMap = new HashMap();
		paraMap.put("uid", uid);
		paraMap.put("upword", upword);
		return teacherDao.login(paraMap);
	}

	@Override
	public List<Teacher> findTeacherByIdnumber(String idnumber) {
		return this.teacherDao.findTeacherByIdnumber(idnumber);
	}

	public TeacherUsrDao getTeacherUsrDao() {
		return teacherUsrDao;
	}

	public void setTeacherUsrDao(TeacherUsrDao teacherUsrDao) {
		this.teacherUsrDao = teacherUsrDao;
	}

	public TeacherDao getTeacherDao() {
		return teacherDao;
	}

	public void setTeacherDao(TeacherDao teacherDao) {
		this.teacherDao = teacherDao;
	}

	
}
